/* Auth.java
 * 
 * Alfred Olschnoegger
 * 26.05.2008
 */

package presentation.controller;

import application.AuthManager;
import application.parser.Parser;
import application.parser.StringParser;

/**
 * Manages the authentication processes 
 *
 * @date 26.05.2008
 * @author Alfred Olschnoegger
 */

public class Auth extends HttpBaseController {

	/**
	 * Processes the auth task
	 */
	public void process() {
		AuthManager auth = new AuthManager();
		StringParser parse = new StringParser();
		
		if(m_Arguments.get("task").equalsIgnoreCase("register") ) {
			
			auth.register(m_Arguments.get("username"), Integer.parseInt(m_Arguments.get("game")),parse);
			

		} else if (m_Arguments.get("task").equalsIgnoreCase("logIn")) {
			
			auth.logIn(m_Arguments.get("username"), Long.parseLong(m_Arguments.get("key")), Integer.parseInt(m_Arguments.get("game")),parse);
		}
		

		m_Request.setAttribute("responseStr",parse.parse());
		redirect();
	}

}


// end of Auth.java
